/*================================================================
*   Copyright (C) 2024 baichao All rights reserved.
*
*   文件名称：main.c
*   创 建 者：baichao
*   创建日期：2024年04月08日
*   描    述：
*
================================================================*/

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

struct ListNode {
  int val;
  struct ListNode *next;
};

bool isPalindrome(struct ListNode *head) {
  int8_t _stack[100000];
  int32_t index = 99999;
  int32_t count = 0;
  struct ListNode *currNode = head;
  while (currNode != NULL) {
    _stack[index--] = currNode->val;
    count++;
    currNode = currNode->next;
  }

  currNode = head;
  for (int i = 0; i < count; i++) {
    if (currNode->val != _stack[100000 - count + i]) {
      return false;
    }
    currNode = currNode->next;
  }
  return true;
}

int main() {
  struct ListNode *currNode = NULL;
  struct ListNode *listA = (struct ListNode *)malloc(sizeof(struct ListNode));

  listA->val = 1;
  listA->next = (struct ListNode *)malloc(sizeof(struct ListNode));
  currNode = listA->next;

  currNode->val = 2;
  currNode->next = (struct ListNode *)malloc(sizeof(struct ListNode));
  currNode = currNode->next;

  currNode->val = 2;
  currNode->next = (struct ListNode *)malloc(sizeof(struct ListNode));
  currNode = currNode->next;

  currNode->val = 1;
  currNode->next = NULL;

  bool ret = isPalindrome(listA);

  printf("%d", ret);

  return 0;
}
